﻿using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;

namespace TrainTicketsRobot
{
    [Serializable]
    class CheckOrderInfo
    {
        public CheckOrderInfo(string strJson) 
        {
            if (!strJson.Contains("\"checkHuimd\":"))
            {
                strJson = strJson.Remove(strJson.Length - 1);
                strJson = strJson + ",\"checkHuimd\":\"\"}";
            }
            if (!strJson.Contains("\"check608\":"))
            {
                strJson = strJson.Remove(strJson.Length - 1);
                strJson = strJson + ",\"check608\":\"\"}";
            }
            if (!strJson.Contains("\"msg\":"))
            {
                strJson = strJson.Remove(strJson.Length - 1);
                strJson = strJson + ",\"msg\":\"\"}";
            }
            if (!strJson.Contains("\"errMsg\":"))
            {
                strJson = strJson.Remove(strJson.Length - 1);
                strJson = strJson + ",\"errMsg\":\"\"}";
            }
            DataContractJsonSerializer dataConSer = new DataContractJsonSerializer(typeof(CheckOrderInfo));
            using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(strJson)))
            {
                CheckOrderInfo checkOrderInfo = dataConSer.ReadObject(ms) as CheckOrderInfo;
                this.checkHuimd = checkOrderInfo.checkHuimd;
                this.check608 = checkOrderInfo.check608;
                this.msg = checkOrderInfo.msg;
                this.errMsg = checkOrderInfo.errMsg;
            }
        }
        public string checkHuimd;
        public string check608;
        public string msg;
        public string errMsg;
    }
}
